#ifndef _CHATMESSAGELAYER_H_
#define _CHATMESSAGELAYER_H_

#include <cocos2d.h>
#include <CCTouch.h>
#include <OIS.h>

using namespace cocos2d;
using namespace std;

class CustomObject : public CCObject {
public:
	int m_ID;
private:

};

class CustomEvent {
public:
	CustomEvent(CCObject* fromObject, SEL_CallFuncO func) {
		this->rec = fromObject;
		this->call = func;
	}

	~CustomEvent() {
		CC_SAFE_DELETE(rec);
		call = NULL;
	}

	CCObject* rec;
	SEL_CallFuncO call;
private:

};

class ChatMessageLayer : public CCLayer,  public OIS::KeyListener {
public:
	virtual bool init();
	virtual void menuCloseCallback(CCObject* pSender);
	virtual void update(ccTime* delta);
	virtual void onExit();

	LAYER_NODE_FUNC(ChatMessageLayer);

	CustomEvent* OnNextPageCallback;
	CustomEvent* OnLastPageCallback;

	inline ChatMessageLayer* AddPage(string s) {
		_MessagePages.push_back(string(s));
		CalculatePages();

		return this;
	}

	bool keyPressed( const OIS::KeyEvent &e );
	bool keyReleased( const OIS::KeyEvent &e );

private:
	bool FinishedLoadingCurrentPage();

	CCLabelBMFont* _CurrentText;
	CCLabelBMFont* _CurrentText2;

	void NextPage();
	void CalculatePages();

	vector<string> _MessagePages;
	int _TotalPages, _CurrentPage;
};

#endif